#include <bits/stdc++.h>
using namespace std;

int n;
char a, b, c;

void dfs(int n, char a, char b, char c)
{
	if(n == 1)
	{
		printf("%c->%d->%c\n", a, 1, b);
		return;
	}
	dfs(n - 1, a, c, b);
	printf("%c->%d->%c\n", a, n, b);
	dfs(n - 1, c, b, a);
}

int main()
{
	cin >> n >> a >> b >> c;
	dfs(n, a, b, c);
	return 0;
}